package com.pb.camera.utils;

import android.media.Image;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;

public class MyTextWatcher   implements  TextWatcher{

	private EditText  edit;
	private ImageView   image;
	
	
	
	public MyTextWatcher(final EditText edit, ImageView image) {
		super();
		this.edit = edit;
		this.image = image;
		image.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(v.getVisibility()==View.VISIBLE)
				{
					edit.setText("");
								
				}
			}
		});
	}

	@Override
	public void beforeTextChanged(CharSequence s, int start, int count,
			int after) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onTextChanged(CharSequence s, int start, int before, int count) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void afterTextChanged(Editable s) {
		// TODO Auto-generated method stub
		
	int len=	edit.getText().toString().length();
	if(len>0)
	{
	image.setVisibility(View.VISIBLE);
	}
	else 
	{
	image.setVisibility(View.INVISIBLE);
		
	}
		
	}
	
	
	

}
